// TODO: CODE REVIEW & CLEANUP!
//
// LaAv.xaml.cs
//

using System;
using System.Windows.Controls;
using HomeUX.ClientControlSupport;
using HomeUX.Synchronization;

namespace HomeUX.ClientApp
{

public partial class LaAv : UserControl, IDisposable
{
    ISyncClient _syncClient;

    public LaAv()
    {
        InitializeComponent();
		Loaded += LaAv_Loaded;
        _syncClient = ClientControlSupport.ClientGlobals.GetSyncClient(this);
        _syncClient.IsOnlineChanged += _syncClient_IsOnlineChanged;
    }

    public void Dispose()
    {
        _syncClient.IsOnlineChanged -= _syncClient_IsOnlineChanged;
    }

    private void LaAv_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
		TheMediaControl.TheTouchTabStrip.SelectedItemDataChanged += TheTouchTabStrip_SelectedItemDataChanged;
        TheTouchTabStrip_SelectedItemDataChanged(null, null);
    }

    private void TheTouchTabStrip_SelectedItemDataChanged(object sender, System.EventArgs e)
    {
        switch (TheMediaControl.TheTouchTabStrip.SelectedItemData)
        {
        case "TheTiVoControl":
            HearButton.Text = "Listen to\nTiVo";
            HearButton.SyncPath = @"Scripts\Living Area\Listen to TiVo";
            WatchButton.Text = "Watch\nTiVo";
            WatchButton.SyncPath = @"Scripts\Living Area\Watch TiVo";
            break;
        case "TheXboxControl":
            HearButton.Text = "N/A";
            HearButton.SyncPath = null;
            WatchButton.Text = "Watch\nXbox";
            WatchButton.SyncPath = @"Scripts\Living Area\Watch Xbox";
            break;
        case "TheMusicControl":
            HearButton.Text = "Listen to Music";
            HearButton.SyncPath = @"Scripts\Living Area\Listen to Music";
            WatchButton.Text = "N/A";
            WatchButton.SyncPath = null;
            break;
        case "TheDvdControl":
            HearButton.Text = "Listen to\nDVD/CD";
            HearButton.SyncPath = @"Scripts\Living Area\Listen to DVD/CD";
            WatchButton.Text = "Watch\nDVD/CD";
            WatchButton.SyncPath = @"Scripts\Living Area\Watch DVD";
            break;
        case "TheVcrControl":
            HearButton.Text = "Listen to\nVCR";
            HearButton.SyncPath = @"Scripts\Living Area\Listen to VCR";
            WatchButton.Text = "Watch\nVCR";
            WatchButton.SyncPath = @"Scripts\Living Area\Watch VCR";
            break;
        }
    }

    void _syncClient_IsOnlineChanged(object sender, IsOnlineChangedEventArgs e)
    {
        TvControlButton.IsEnabled = e.IsOnline;
    }

    private void TvControlButton_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        ClientUtil.ShowDialog(this, new LaTv(), null);
    }
}

}

